package cn.edu.dgut.xhx.covid;

import cn.edu.dgut.xhx.covid.service.CovidService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.web.client.RestTemplate;

@EnableScheduling
@SpringBootApplication
public class CovidSecurityApplication {

	public static void main(String[] args) {
		SpringApplication.run(CovidSecurityApplication.class, args);
	}

	@Bean
	public CommandLineRunner commandLineRunner(CovidService covidService){
		return args -> {
			covidService.getData();
		};
	}


	@Configuration
	class BeanConfiguration{

		@Autowired
		private RestTemplateBuilder builder;

		@Bean
		public RestTemplate restTemplate(){
			return builder.build();
		}
	}

}
